﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace lcmyjobs.Web.reward
{
    public partial class enlistjobs : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {


                if (Application["webid"] != null)
                {
                    int atid = Convert.ToInt32(Application["webid"]);

                    BindAscx(atid);
                    this.Title = string.Format("悬赏招聘   人才网   招聘网   求职网   猎头网   {0}", Application["webname"].ToString());
                }
                if (Request["enterprise_rid"] != null && Request["rewardId"] != null)
                {
                    int rid = Convert.ToInt32(Request["enterprise_rid"]);
                    int rewardId = Convert.ToInt32(Request["rewardId"]);
                    //this.lblid.Text = rid.ToString();
                    BindLeftInfo(rid, rewardId);
                }
                else
                {
                    if (Application["webid"] != null)
                    {
                        int atid = Convert.ToInt32(Application["webid"]);


                        int c_isfrist = 0;
                        int c_reward = 0;
                        int c_vip = 0;
                        int c_hunter = 0;
                        int c_newjob = 0;
                        int c_workerclass = 0;


                        DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetJobsInfo(false, true, false, false, false, false,
                                                            atid, 1, 1,
                                                            out c_isfrist, out c_reward, out c_hunter, out c_vip, out c_newjob, out c_workerclass);
                        if (ds.Tables[0].Rows.Count == 1)
                        {

                            this.Response.Redirect("enlist-" + ds.Tables[0].Rows[0]["enterprise_rid"] + "-" + ds.Tables[0].Rows[0]["enterprise_reward_id"] + ".html");
                        }
                    }
                }

            }
        }

        private void BindAscx(int atid)
        {
            //this.GridRewardJobs1.isAspPager = true;
            //this.GridRewardJobs1.atid = atid;
           // this.GridRewardJobs1.disCount = 20;
        }

        private void BindLeftInfo(int enterprise_rid, int rewardId)
        {
            DataSet ds = new lcmyjobs.BLL.enterprise_releasejob().GetBasicAndJobsInfoByRid(enterprise_rid);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                this.lbl_areaname.Text = row["area_name"].ToString();
                this.lbl_bh.Text = rewardId.ToString().PadLeft(6, '0');
                this.lbl_jobduty.Text = row["jobduty"].ToString();
                this.lbl_jobsname.Text = row["jobs_name"].ToString();
                this.Title = string.Format("悬赏招聘：{1}   人才网   招聘网   求职网   猎头网   {0}", Application["webname"].ToString(), this.lbl_jobsname.Text);
                this.lbl_requirement.Text = row["jobrequirement"].ToString();

            }
            if (ds.Tables[1].Rows.Count > 0)
            {
                DataRow row = ds.Tables[1].Rows[0];
                this.lbl_dwgm.Text = row["dwgm"].ToString();
                this.lbl_trade.Text = row["trade_name"].ToString();
            }
            if (ds.Tables[2].Rows.Count > 0)
            {
                DataRow row = ds.Tables[2].Rows[0];

                this.lbl_price.Text = row["price"].ToString();
                this.lbl_rtime.Text = row["rtime"].ToString();
                //this.lbl_rewardId.Text = row["enterprise_reward_id"].ToString();
            }
        }

        protected void btn_jb_Click(object sender, EventArgs e)
        {
            string str = "offer_en.aspx?rewardBh=" + this.lbl_bh.Text + "&rewardName=" + this.lbl_jobsname.Text;
            Response.Redirect(str);

        }

        protected void btnxidan_Click(object sender, EventArgs e)
        {
            Response.Redirect("checkEnLogin.html");
        }
    }
}